<template>
	<view class="my_info br6">
		<!--地址-->
		<view class="add-address d-s-c" @click="addAddress()" v-if="!Address">
			<view class="icon-box mr10">
				<text class="icon iconfont icon-dizhi"></text>
			</view>
			<text>请添加收货地址</text>
		</view>
		<view class="address-defalut-wrap" @click="addAddress()" v-else style="padding: 32rpx;">
			<view class="d-b-c">
				<view class="add-addr flex-1">
					<view class="icon-box mr10 f-s-0">
						<text class="icon iconfont icon-dizhi"></text>
					</view>
					<view class="flex-1">
						<view class="info mb10">
							<text class="province-c-a f28 fb text-ellipsis-2">
								{{ Address.region.province }}{{ Address.region.city }}
								{{ Address.region.region }}{{ Address.detail }}
							</text>
						</view>
						<view class="gray9 f22">
							<text>
								{{ Address.name }}{{ Address.phone }}
							</text>
						</view>
					</view>
				</view>
				<view class="ml80 f-s-0">
					<button class="btn" v-if="orderDetail.order_status.value==1">修改</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				Address: null,
				tokenInfo: ""
			}
		},
		// 'Address',
		props: ['exist_address', 'orderDetail'],
		onLoad(val) {},
		mounted() {
			console.log("111", uni.getStorageSync("address"));
			this.Address = uni.getStorageSync("address");
			console.log(this.Address, 'Address')
			let addressObj = {};
			addressObj.fullname = this.Address.name;
			addressObj.mobilePhone = this.Address.phone;
			addressObj.province = this.Address.region.province;
			addressObj.city = this.Address.region.city;
			addressObj.area = this.Address.region.region;
			addressObj.address = this.Address.detail;
			// console.log(addressObj);
			this.$emit('changestates', addressObj);
		},
		activated() {
			console.log("111", uni.getStorageSync("address"));
			this.Address = uni.getStorageSync("address");
			console.log(this.Address, 'Address')
			let addressObj = {};
			addressObj.fullname = this.Address.name;
			addressObj.mobilePhone = this.Address.phone;
			addressObj.province = this.Address.region.province;
			addressObj.city = this.Address.region.city;
			addressObj.area = this.Address.region.region;
			addressObj.address = this.Address.detail;
			// console.log(addressObj);
			this.$emit('changestates', addressObj);
		},
		onShow() {

		},
		methods: {
			/*添加地址*/
			addAddress() {
				this.tokenInfo = uni.getStorageSync('token');
				// if (!this.tokenInfo) {
				// 	if (navigator.userAgent.indexOf('MicroMessenger') > -1) {
				// 		// 当前是微信浏览器  
				// 		this._post('user.usermp/login', {
				// 			referee_id: 0
				// 		}, res => {
				// 			console.log(res, 'data');
				// 			window.location.href = res.data
				// 		})
				// 	} else {
				// 		// 不在微信浏览器中，弹窗提示用户  
				// 		uni.showModal({
				// 			title: '提示',
				// 			content: '为了获得更好的体验，建议您在微信浏览器中打开此页面',
				// 			showCancel: false,
				// 		});
				// 	}
				// 	return
				// }

				if (this.orderDetail.order_status.value !==1) {
					return
				}
				let url = '/pages/user/address/address?source=order';
				// if (!this.exist_address) {
				// 	url = '/pages/user/address/add/add?delta=1';
				// }
				uni.navigateTo({
					url
				})

				// let url = '/pages/user/address/address?source=order';
				// if (!this.exist_address) {
				// 	url = '/pages/user/address/add/add?delta=1';
				// }

				// this.gotoPage(url);
				// uni.navigateTo({
				// 	url:url
				// })
			}
		}
	}
</script>

<style lang="scss">
	.info {
		font-size: 33rpx;
		line-height: 43rpx;
	}

	.add-addr {
		display: flex;
		align-items: center;
	}

	.tel {
		font-size: 27rpx;
		color: #999999;
	}

	.choose-address {
		width: 88rpx;
		height: 88rpx;
		margin-right: 35rpx;
	}

	.icon-dizhi {
		margin-right: 25rpx;
		color: #00c8be;
		font-size: 60rpx;
	}

	.addree_icon {
		width: 42rpx;
		height: 42rpx;
	}

	.my_info {
		background-color: #FFFFFF;
		margin-top: 16rpx;
	}

	.icon-box .icon.icon-dizhi1 {
		@include font_color('font_color');
		font-size: 44rpx;
	}

	.my_info .icon.icon-jiantou {
		color: #333333;
		font-size: 24rpx;
	}

	.btn {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 60px;
		height: 30px;
		border-radius: 30px;
		border: 1px solid black;
	}
</style>